<?php
namespace data\sys;
class AreaData extends \data\BaseData{

    /**
     * 读取一个地区列表
     */
    public function getList($param){
        $fields = ['pcode','depth'];
        $where  = $this->parseWhere($fields,$param);
        $list   = M('sys_area')->where($where)->order('code asc')->select();
        $total  = M('sys_area')->where($where)->count();
        return array(            
            'total'     => $total,
            'list'      => $list
        );
    }

    /**
     * 读取一个地区信息
     */
    public function getInfo($code){
        if(!$code) return [];
        $where['code'] = $code;
        $info = M("sys_area")->where($where)->find();
        return $info;
    }

    /**
     * 获取某个地区的信息 模糊搜索
     */
    public function getAreaByName($name){
        if(!$name) return [];
        $where['name'] = ['like',"%".$name."%"];
        $info = M("sys_area")->where($where)->find();
        return $info;
    }





}